package study.corejava.extend;

/**
 * This program demonstrates inheritance.
 * @version 1.21 2004-02-21
 * @author Cay Horstmann
 */
public class ManagerTest {
	
	public static void main(String[] args) {
		// construct a Manager object
		Manager boss = new Manager("Carl Cracker", 80000, 1987, 12, 15);
		
		boss.setBonus(5000);

		Employee[] staff = new Employee[3];

		// fill the staff array with Manager and Employee objects

		staff[0] = boss; //居然将子类对象的引用放入到了父类型的数组里面了，匪夷所思啊
		
		staff[1] = new Employee("Harry Hacker", 50000, 1989, 10, 1);
		staff[2] = new Employee("Tommy Tester", 40000, 1990, 3, 15);

		// print out information about all Employee objects
		for (Employee e : staff) {
			System.out.println("name=" + e.getName() + ",salary="
					+ e.getSalary());
		}
		
		//boss.getBonus();
		
		//((Manager)staff[0]).getBonus();
		Manager[] managers = new Manager[10];
		
		//子类数组的引用可以转换成超类数组的引用
		Employee[] employees = managers; 
		
		//managers[0].
		//employees[0].
		
		//将一个普通雇员加到了经理的行列了哦
		//至此，managers[0]和employees[0]都指向同一个Manager对象
		employees[0] = new Employee("Aric",666666,1987,5,25);
		
	}
}
